<!DOCTYPE html>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('生成卓越班')" />
</head>
<body>
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <h1>初次筛选人数：[[${firstPass}]]</h1>
            <button type="button" class="btn btn-warning" onclick="firstPass()">初次筛选</button>
        </div>
        <div class="col-sm-12 search-collapse">
            <h1>机试筛选人数：[[${secondPass}]]</h1>
            <button type="button" class="btn btn-warning" onclick="secondPass()">机试筛选</button>
        </div>
        <div class="col-sm-12 search-collapse">
            <h1>卓越班生成人数：[[${count}]]</h1>
            <button type="button" class="btn btn-warning" onclick="generate()">生成卓越班</button>
        </div>
    </div>
</div>

<th:block th:include="include :: footer" />
<script type="text/javascript">
    function generate() {
        var count =[[${count}]];
        $.modal.confirm('确认生成卓越班吗？',function(){
            var config = {
                type: "post",
                url: "/system/generate",
                dataType: "json",
                data: {
                    count: count
                },
                beforeSend: function () {
                    $.modal.loading("正在处理中，请稍后...");
                },
                success: function (result) {
                    if (result.msg === "操作失败") {
                        $.modal.msgWarning("已成功，但人数不够");
                    }
                    else{
                        $.modal.msgSuccess(result.msg);
                    }
                    Notice();
                    $.modal.closeLoading();
                    // window.parent.frames.location.href = ctx + "index";
                }
            };
            $.ajax(config);
        });
    }
    function firstPass() {
        var firstPass =[[${firstPass}]];
        $.modal.confirm('确认进行初次筛选吗？',function(){
            var config = {
                type: "post",
                url: "/system/firstPass",
                dataType: "json",
                data: {
                    firstPass: firstPass
                },
                beforeSend: function () {
                    $.modal.loading("正在处理中，请稍后...");
                },
                success: function (result) {
                    $.modal.closeLoading();
                    if (result.msg === "操作失败") {
                        $.modal.msgWarning("已成功，但人数不够");
                    }
                    else{
                        $.modal.msgSuccess(result.msg);
                    }
                    Notice();
                    $.modal.closeLoading();
                }
            };
            $.ajax(config);
        });
    }
    function secondPass() {
        var secondPass =[[${secondPass}]];
        $.modal.confirm('确认进行机试筛选吗？',function(){
            var config = {
                type: "post",
                url: "/system/secondPass",
                dataType: "json",
                data: {
                    secondPass: secondPass
                },
                beforeSend: function () {
                    $.modal.loading("正在处理中，请稍后...");
                },
                success: function (result) {
                    if (result.msg === "操作失败") {
                        $.modal.msgWarning("已成功，但人数不够");
                    }
                    else{
                        $.modal.msgSuccess(result.msg);
                    }
                    Notice();
                    $.modal.closeLoading();
                }
            };
            $.ajax(config);
        });
    }

    function Notice(){
        $.modal.confirm("是否要发布公告通知学生", function() {
            $.modal.openFull("新建公告", "/system/notice/add");
        });
    }
</script>
</body>
</html>
